package com.jiangyg.mall.order.service;

import com.jiangyg.mall.core.support.restful.Pagination;
import com.jiangyg.mall.db.mybatis.BaseServiceImpl;
import com.jiangyg.mall.order.dao.OrderReturnApplyDao;
import com.jiangyg.mall.order.dto.OrderReturnApplyDTO;
import com.jiangyg.mall.order.entity.OrderReturnApply;
import com.jiangyg.mall.order.vo.OrderReturnApplyVO;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class OrderReturnApplyServiceImpl extends BaseServiceImpl<OrderReturnApplyDao, OrderReturnApply> implements OrderReturnApplyService {

    @Autowired
    public OrderReturnApplyServiceImpl(OrderReturnApplyDao orderReturnApplyDao) {
        super(orderReturnApplyDao);
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public Pagination<OrderReturnApplyVO> selectPagination(Pagination<OrderReturnApplyVO> pagination) throws Exception {
        return this.executeSelectPagination(pagination, OrderReturnApplyVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean saveOrUpdate(OrderReturnApplyDTO dto) throws Exception {
        return this.executeSaveOrUpdate(dto) > 0;
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public OrderReturnApplyVO selectById(Long orderReturnApplyId) throws Exception {
        return this.executeSelectById(orderReturnApplyId, OrderReturnApplyVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean delete(List<Long> orderReturnApplyIds) {
        return this.baseMapper.deleteBatchIds(orderReturnApplyIds) > 0;
    }

}
